EMS 2013 Start-Job -InitializationScript {??Launch EMS??}

I am attempting to create a PowerShell script utilizing Start-Job against each Exchange database. How can I possibly initialize the job with the 2013 EMS? In 2010 I was able to initialize by using adding the 2010 snapin but from what I understand adding the 2013 snapin is not supported.

A sample of the beginning of my script is below. The Start-Job code in question is on the last few lines.


# Query all mailbox databases that are members of a DAG and that are not marked as
#  recovery databases.
$DAGDbs = Get-MailboxDatabase | Where-Object {$_.mastertype -eq "DatabaseAvailabilityGroup" -and $_.recovery -ne "true"}

# Use a Foreach loop to process each database.
ForEach ($DAGDb in $DAGDbs){
# Check the running status of jobs generated by this script to help throttle the
#  concurrent jobs.
$CheckJobs = Get-Job -Name *GetMailboxes | Where-Object {$_.State -eq 'Running'}
	# Use the If statement to throttle the number of concurrent jobs to four.
	if ($CheckJobs.count -le 5){
		# When the number of running jobs is less than or equal to four, start
		#  another job using the DAG databases currently being processed within
		#  the ForEach loop.
		Start-Job -Name "$DAGDb GetMailboxes" -InitializationScript {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010} `
		-ArgumentList ($DAGDb.name, $_) -ScriptBlock {


February 23rd, 2015 2:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics